# brings together different models and modules to use together

from elixir import *
import Extractor as ME
# brings in the code that extracts the MMPI scores
import ScalesElixirModel as SEM
# creates the table for MMPI scales as well as contains DB loader
import RawElixirModel as REM
# creates teh table for MMPI raw data and contains DB loader
import DBTableModel as DBT
# talks to DBT created by django

setup_all()
create_all()

# code for pulling an MMPI record from table in SQL
MmpiRow = DBT.MmpiText.query.filter_by(id=1).one()
TextColumn = MmpiRow.MMPI_report
MmpiLines = TextColumn.splitlines()


ME2 = ME.MmpiExtractor()
# creates an instance of this class
ME2.loadLines(MmpiLines)
ME2.extractRaw(MmpiLines)
ME2.extractScales(MmpiLines)
ME2.extractSubscales(MmpiLines)
# tells it to run the functions within the class

RawLoad = REM.RawDbLoader()
RawLoad.load_database(ME2.d)

ScaleLoad = SEM.ScaleDbLoader()
ScaleLoad.load_database(ME2.ProRS)
ScaleLoad.load_database(ME2.ProTS)
ScaleLoad.load_database(ME2.SupRS)
ScaleLoad.load_database(ME2.SupTS)
ScaleLoad.load_database(ME2.ConRS)
ScaleLoad.load_database(ME2.ConTS)
ScaleLoad.load_database(ME2.NonK)
ScaleLoad.load_database(ME2.DpR)
ScaleLoad.load_database(ME2.DpT)
ScaleLoad.load_database(ME2.HyR)
ScaleLoad.load_database(ME2.HyT)
ScaleLoad.load_database(ME2.PdR)
ScaleLoad.load_database(ME2.PdT)
ScaleLoad.load_database(ME2.PaR)
ScaleLoad.load_database(ME2.PaT)
ScaleLoad.load_database(ME2.ScR)
ScaleLoad.load_database(ME2.ScT)
ScaleLoad.load_database(ME2.MaR)
ScaleLoad.load_database(ME2.MaT)
ScaleLoad.load_database(ME2.SiR)
ScaleLoad.load_database(ME2.SiT)
session.commit()




